#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    pushbutton=new QPushButton(this);//创建按钮对象并将其添加到对象树中
    pushbutton->setText("Hello World");//给这个按钮写入文本信息

    connect(pushbutton,&QPushButton::clicked,this,&Widget::handler);

}
void Widget::handler()
{
    if(pushbutton->text()==QString("Hello World"))
    {
        pushbutton->setText("Hello Qt");
    }
    else
    {
        pushbutton->setText("Hello World");
    }
}

Widget::~Widget()
{
    delete ui;
}

